#ifndef OBJECT_H_
#define OBJECT_H_

#include <list>
#include "xform_node.h"
#include "mesh.h"
#include "material.h"

namespace goatgfx {

enum DrawMode {
	DRAW_DEFAULT,
	DRAW_WIREFRAME,
	DRAW_VERTICES
};


class Object : public XFormNode {
private:
	Mesh *mesh;	///< no ownership, just keeping the pointer around
	static DrawMode draw_mode;

	bool setup_bones(long msec) const;

public:
	Material material;

	Object();

	/// destroy this object and all the hierarchy of objects hanging below it
	void destroy_all();

	void set_mesh(Mesh *m);
	Mesh *get_mesh();
	const Mesh *get_mesh() const;

	/// get all the meshes of the subtree rooted in this object @{
	std::list<Mesh*> get_all_meshes();
	std::list<const Mesh*> get_all_meshes() const;
	/// @}

	AABox get_aabbox() const;
	Sphere get_bsphere() const;

	void draw(long msec = 0) const;

	bool intersect(const Ray &ray, HitPoint *hit = 0) const;

	/// this is mostly for tools, to allow drawing only the wireframe or vertices
	static DrawMode set_draw_mode(DrawMode mode);
};

}	// namespace goatgfx

#endif	// OBJECT_H_
